package com.atguigu.mapjoin;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;

public class MJDriver {
    public static void main(String[] args) throws IOException, URISyntaxException, ClassNotFoundException, InterruptedException {

        Job job = Job.getInstance(new Configuration());

        //添加缓存文件
        job.addCacheFile(new URI("file:///D:/io/input9/pd.txt"));
        job.setMapperClass(MJMapper.class);
        job.setMapOutputKeyClass(OrderBean.class);
        job.setMapOutputValueClass(NullWritable.class);
        //最终的类型是Mapper输出的key,value(因为没有Reducer)
        job.setOutputKeyClass(OrderBean.class);
        job.setOutputValueClass(NullWritable.class);

        job.setNumReduceTasks(0);//没有ReduceTask

        FileInputFormat.setInputPaths(job,new Path("D:/io/input9/order.txt"));
        FileOutputFormat.setOutputPath(job,new Path("D:/io/output999"));

        job.waitForCompletion(true);
    }
}
